﻿<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    assembly="JSC.Portal.Core" namespace="JSC.Portal.Entities">

	<class name="Section" table="jsc_section" lazy="false">

		<!-- start Base on every entity -->
		<id name="Id" column="sectionid" unsaved-value="-1">
			<generator class="native">
				<param name="sequence">jsc_section_sectionid_seq</param>
			</generator>
		</id>

		<property name="Name" column="name" not-null="true"/>
		<property name="Description" column="description"/>
		<!-- end Base on every entity -->

		<property name="Placeholder" column="placeholder" not-null="true"/>
		<property name="Position" column="position" not-null="true"/>
    <property name="ShowName" column="showname" not-null="true"/>
		<property name="ValidFrom" column="validfrom" not-null="true"/>
		<property name="ValidTill" column="validtill" />
    <property name="CreatedOn" column="createdtimestamp" type="DateTime"/>
    <property name="ModifiedOn" column="modifiedtimestamp" type="DateTime"/>
    <many-to-one name="CreatedByUser" class="PortalUser" column="createdby" not-null="false" not-found="ignore"/>
    <many-to-one name="ModifiedByUser" class="PortalUser" column="modifiedby" not-null="false" not-found="ignore"/>
		<many-to-one name="ModuleType" class="ModuleType" column="moduletypeid" not-null="true" />
		<many-to-one name="Page" class="PortalPage" column="pageid" not-null="true" />
    
    <bag name="SectionPermissions" cascade="all" lazy="true" table="jsc_sectionrole">
      <key column="sectionid" />
      <composite-element class="SectionPermission">
        <parent name="Section" />
        <property name="ViewAllowed" column="viewallowed" type="Boolean" />
        <property name="EditAllowed" column="editallowed" type="Boolean" />
        <many-to-one name="Role" class="Role" column="roleid" cascade="none" />
      </composite-element>
    </bag>

    <bag name="Settings" cascade="all" lazy="true" table="jsc_sectionmodulepropertyvalue">
      <key column="sectionid" />
      <composite-element class="SectionModulePropertyValue">
        <parent name="Section" />
        <property name="Value" column="value" />
        <many-to-one name="ModuleProperty" class="ModuleProperty" column="modulepropertyid" cascade="none" />
      </composite-element>
    </bag>         

		<!--<map name="Settings" table="jsc_sectionmodulepropertyvalue" lazy="true" cascade="all">
			<key column="sectionid" />
			<index column="propertyname" type="String"/>
			<element column="value" type="String" />
		</map>-->
		
	</class>
</hibernate-mapping>